"""
内容:将累计销量封装成一个类

"""
#引入
from ECshop.common.base import create_browser,Base,create_browser_op
import time

class PageSale01(Base):
    #属性
    url = 'http://localhost:8080/ecshop/user.php'
    first = ('link text', '首页')
    sport_camera = ('xpath', ("//img[@src='images/201605/thumb_img/64_thumb_G_1462952811633.jpg']"))
    buy = ('xpath', ("//img[@src='themes/default/images/buybtn1.png']"))
    pay = ('xpath', ("//img[@src='themes/default/images/checkout.gif']"))
    put_in = ('xpath', ("//input[@src='themes/default/images/bnt_subOrder.gif']"))
    first1 = ('link text', '首页')
    sport_camera1 = ('xpath', ("//img[@src='images/201605/thumb_img/64_thumb_G_1462952811633.jpg']"))
    sale_number=("xpath",("//li[@class='clearfix']/dd[3]"))
    #方法
    #方法
    #打开网页
    def page_sale_web(self):
        self.base_open_web(self.url)
    #点击首页
    def page_sale_first(self):
        self.base_click(self.first)
    #点击运动相机
    def page_sale_sport_camera(self):
        self.base_click(self.sport_camera)
    #点击购买
    def page_sale_buy(self):
        self.base_click(self.buy)
    # 立即结算
    def page_sale_pay(self):
        self.base_click(self.pay)
    # 立即提交
    def page_sale_in_put(self):
        self.base_click(self.put_in)
    # 返回首页
    def page_sale_firest1(self):
        self.base_click(self.first1)
    #点击运动相机
    def page_sale_sport_camera1(self):
        self.base_click(self.sport_camera1)
    #查询销量
    def page_sale_number(self):
        result=self.base_get_text(self.sale_number)
        return result
    #关闭网页
    def page_sale_quit(self):
        self.base_quit()

if __name__ == '__main__':
    s1=PageSale01(create_browser_op(r'C:\Users\lenovo\AppData\Local\Google\Chrome\User Data'))
    #打开网页
    s1.page_sale_web()
    #点击首页
    s1.page_sale_first()
    #点击运动相机
    s1.page_sale_sport_camera()
    #点击购买
    s1.page_sale_buy()
    #点击结算
    s1.page_sale_pay()
    #点击提交
    s1.page_sale_in_put()
    #返回首页
    s1.page_sale_firest1()
    #点击运动相机
    s1.page_sale_sport_camera1()
    #查询销量
    print(s1.page_sale_number())
